package com.sanrxteam.upload.DB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ResourceBundle;

import com.mysql.jdbc.Statement;

public class DBUtils {
	private static String user;
	private static String password;
	private static String url;
	private static String driverClass;
	static {
		ResourceBundle rb = ResourceBundle.getBundle("db");
		driverClass = rb.getString("driverClass");
		user = rb.getString("user");
		password = rb.getString("password");
		url = rb.getString("url");
		
		try {
			Class.forName(driverClass);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public static Connection getConnection() throws Exception {
		return DriverManager.getConnection(url,user,password);
	}
	
	public static void closeAll(ResultSet rs,PreparedStatement sttm,Connection conn) throws SQLException {
		if(rs != null) {
			rs.close();
		}
		if(sttm != null) {
			sttm.close();
		}
		if(conn != null) {
			conn.close();
		}
	}

	
}
